package com.chen.rocketmq;

import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.http.HttpEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

public class Main {
    public static void main(String[] args) throws IOException {
        try (CloseableHttpClient httpClient = HttpClients.createDefault()){
            HttpPost httpPost = new HttpPost("https://dapp.baoqi56.com/app-v1/ums-auth/login/app/third_source");
            httpPost.setHeader("Content-Type", "application/json"); // 必须设置JSON请求头
            httpPost.setHeader("Accept", "application/json");
            httpPost.setHeader("User-Agent","Apifox/1.0.0 (https://apifox.com)");
            Map<String, Object> jsonData = new HashMap<>();
            jsonData.put("idCardNumber", "P9yV0Oi5s/JOKs9mOKDsVWT+gGL5yy5hsAKQQddoCBb2lBXYbi+8Y4Jw2sQj3UbbRvUUhzuwfyKdbHkKJHxXNIgp0ZI2QEuCkO+PO+63SM8e3y7gvUeJgDYUeZU/thh44Jk0XOqYxBasGPT55Ko4AKj54qZU9OVGQTAnd2PGgPM=");
            ObjectMapper objectMapper = new ObjectMapper();
            String jsonBody = objectMapper.writeValueAsString(jsonData);
            httpPost.setEntity(new StringEntity(jsonBody, "UTF-8"));
            try (CloseableHttpResponse response = httpClient.execute(httpPost)) {
                HttpEntity responseEntity = response.getEntity();
                if (responseEntity != null) {
                    String responseJson = EntityUtils.toString(responseEntity, "UTF-8");
                    System.out.println("响应结果: " + responseJson);
                }
            }
        }

    }
}
